package tsing.javase.caffenie;

import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

/**
 * @Author Tsing/吴清平
 * @Date 2023/1/29 18:28
 * @Version 1.0
 */

@Component
public class CaffenineCache {
    private Cache<String, String> cache ;

    public CaffenineCache(){

        putCache();
    }


    private void putCache(){
        if(cache==null){
            cache =  Caffeine.newBuilder().build();
        }
        // 存数据
        cache.put("gf", "赵丽颖");
        cache.put("name", "Tsing");


    }


    public Cache<String,String> gettCache(){
        return cache;
    }
}

